#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Time       :   9:29
# Author     : Y4
# Site       : 
# File       : 015 案例.py
# Software   : PyCharm

import urllib.request
import gevent
from gevent import monkey
monkey.patch_all()

def download(path):
    resp = urllib.request.urlopen(path)
    content = resp.read()
    print('下载了{}的数据,长度是:{}'.format(path,len(content)))

if __name__ == '__main__':
    urls = ['http://www.163.com','http://www.qq.com','http://www.baidu.com']
    url_list = []

    for i in urls:
        url_list.append(gevent.spawn(download, i))

    gevent.joinall(url_list)

